#include "ocin_prtr_omni.h"

void ocin_prtr_omni::init (tsim_object *parent, string _name) {
  
  name = _name;
  tsim_module::init (parent, name);

  top_p = (ocin_top *) parent;

#ifdef DEBUG
  {
    stringstream tmp;
    tmp  << "Initializing the prerouter ";
    ocin_name_debug(name,tmp.str());
  }
#endif

  // Initialize the stats object
  stats.init(node_inst_data, nodes);

  //  stats.print();                // print inited object
  
}



// This function takes a msg pointer and sets its "preroute" vector of
// output ports for each hop to the set of output ports generated by
// the stats' route method.
void ocin_prtr_omni::preroute_msg(ocin_msg * msg, string src, string dest) {
  

  int dimensions = msg->src_addr.size();

  stats.route(msg, src, dest);  // routing happens in the stats thing

  // truncate to a given number of hops, when preroute route unit
  // detects a truncated list w/o output port it will re-preroute
  if (param_repreroute_hops != 0) {  // param_repreroute is number of hops
                                // to route at each time routing step
    msg->preroutes.resize((int)param_repreroute_hops);
  }
    

}
  

// this is where we grab the cost_reg values
void ocin_prtr_omni::update() { 

  stats.update();
}
